package com.hzzy.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hzzy.IDao.HzCheckDormMapper;
import com.hzzy.IDao.HzDormitoryCheckinsMapper;
import com.hzzy.bean.HzDormMember;
import com.hzzy.bean.HzDormitoryCheckins;
import com.hzzy.bean.HzTeacher;
import com.hzzy.service.HzCheckDormService;

/**
 * 寝室点到
 * @author L
 *
 */
@Service
public class HzCheckDormServiceImp implements HzCheckDormService {
	@Autowired
	private HzCheckDormMapper hzCheckDormMapper;
	@Autowired
	private HzDormitoryCheckinsMapper hzDormitoryCheckinsMapper;

	/**
	 * 查询寝室学生
	 */
	public List<HzDormMember> queryDormMember(Map<String, Object> param) {
		
		return hzCheckDormMapper.queryDormMember(param);
	}


	/**
	 * 更具寝室长id查询寝室联系人列表
	 * @param param
	 * @return
	 */
	public List<HzTeacher> queryDormContactByStudentId(Map<String, Object> param) {
		return hzCheckDormMapper.queryDormContactByStudentId(param);
	}

	/**
	 * 插入点到记录
	 */
	public int addDormCheck(HzDormitoryCheckins param) {
		return hzDormitoryCheckinsMapper.insert(param);
	}

	/**
	 * 查询今天是否已经点到
	 */
	public List<HzDormitoryCheckins> checkDormCheckinsByStudentId(Map<String, Object> param) {
		return hzCheckDormMapper.checkDormCheckinsByStudentId(param);
	}

	/**
	 * 查询该学号当天的点到状态
	 */
	public int checkDormMemberstateByStudentId(String studentid,String date) {
		Map<String, Object> param = new HashMap();
		param.put("studentid", studentid);
		param.put("date",date);
		return hzCheckDormMapper.checkDormMemberstateByStudentId(param)==null?0:hzCheckDormMapper.checkDormMemberstateByStudentId(param);
	}

	/**
	 * 修改已经签到的记录
	 */
	public int updateDormCheck(String studentid, int dcstate,String date) {
		Map<String, Object> param = new HashMap();
		param.put("studentid", studentid);
		param.put("dcstate",dcstate);
		param.put("date",date);
		return hzCheckDormMapper.updateDormCheck(param);
	}


	public int checkDormMemberischeckByStudentId(String studentid, String date) {
		Map<String, Object> param = new HashMap();
		param.put("studentid", studentid);
		param.put("date",date);
		return hzCheckDormMapper.checkDormMemberischeckByStudentId(param);
	}
	


}
